﻿//-----------------------------------------------------------------------
// <copyright>
//     Copyright (c) Artur Mustafin. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System;
using Excel.Expressions.Compiler;
using Expressions.Compiler;
using Expressions.Compiler.Interfaces;

namespace Excel.Expressions
{
    internal partial class Nonterminals
    {
        private static Rules<char> _cell_expression()
        {
            return new Rules<char> 
            {
                () => cell_function_definition[false] + Terminal<char>.Default,       
                () => E[false] + Terminal<char>.Default
            };
        }
    }

    internal partial class Expressions
    {
        private static Func<CellExpression, IExpressionTree<char>, CellExpression> _cell_expression()
        {
            return (a, b) =>
            {
                if (b[0].Context.Token.Equals(Nonterminals.cell_function_definition))
                {
                    return cell_function_definition[a, b[0]];
                }
                if (b[0].Context.Token.Equals(Nonterminals.E))
                {
                    return E[a, b[0]];
                }
                throw new NotSupportedException("Input token is not supported");
            };
        }
    }
}
